package com.skjanyou.ui.saoui.view;

import java.awt.Cursor;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;

import javax.swing.JLabel;

import com.skjanyou.utils.ImageUtil;
import com.skjanyou.view.view.SkjanyouButton;
import com.skjanyou.view.view.SkjanyouDialog;

public class SAOUIMessage extends SkjanyouDialog {
	private static final long serialVersionUID = "SAOMessage".hashCode();
	private SAOUIMessage view = this;
	private static BufferedImage image = ImageUtil.getImage("src/com/skjanyou/ui/saoui/resources/Images/background/message.png");
	private BufferedImage image_ok = ImageUtil.getImage("src/com/skjanyou/ui/saoui/resources/Images/etc/save.png");
	private BufferedImage image_cancel = ImageUtil.getImage("src/com/skjanyou/ui/saoui/resources/Images/etc/cancel.png");
	private String message = null;
	private JLabel lb_message = new JLabel();
	private SkjanyouButton sjb_ok = new SkjanyouButton(image_ok);
	private SkjanyouButton sjb_cancel = new SkjanyouButton(image_cancel);
	
	
	public SAOUIMessage(String message){
		super(image);
		this.message = message;
		initView();
		initListener();
	}
	
	private void initView(){
		this.setSize(image.getWidth(), image.getHeight());
		this.setLayout(null);
		this.lb_message.setText(message);
		this.lb_message.setBounds(30, 100, 100, 30);
		this.sjb_ok.setLocation(getWidth() / 4 - image_ok.getWidth() / 2, 185);
		this.sjb_cancel.setLocation(3 * getWidth() / 4 - image_ok.getWidth() / 2, 185);
		this.sjb_ok.setCursor(new Cursor(Cursor.HAND_CURSOR));
		this.sjb_cancel.setCursor(new Cursor(Cursor.HAND_CURSOR));
		this.sjb_ok.setMove(false);
		this.sjb_cancel.setMove(false);
		this.add(lb_message);
		this.add(sjb_ok);
		this.add(sjb_cancel);
	}
	
	private void initListener(){
		this.sjb_ok.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				view.setVisible(false);
			}
		});
		this.sjb_cancel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				view.dispose();
			}
		});
	}
}
